
<%@ page import="org.gtesoreria.Prestamo" %>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <meta name="layout" content="main" />
        <g:set var="entityName" value="${message(code: 'prestamo.label', default: 'Prestamo')}" />
        <title>Prestamos</title>
        <modalbox:modalIncludes />
    </head>
    <body>
        <div class="nav" style="display:none">
            <span class="menuButton"><a class="home" href="${createLink(uri: '/')}"><g:message code="default.home.label"/></a></span>
            <span class="menuButton"><g:link class="create" action="create"><g:message code="default.new.label" args="[entityName]" /></g:link></span>
        </div>
        <div class="body">
            <h1>Prestamos</h1>
            <g:if test="${flash.message}">
            <div class="message">${flash.message}</div>
            </g:if>
            <div class="list">
                <table>
                    <thead>
                        <tr>
                        	<g:sortableColumn property="afiliado.legajo" title="${message(code: 'prestamo.afiliado.label', default: 'Legajo')}" />
                        	<g:sortableColumn property="afiliado.apellidoNombre" title="${message(code: 'prestamo.afiliado.label', default: 'Afiliado')}" />
                        	<th style="width:4em">Imp Cuota</th>
                        	<th style="width:4em">Cant. Cuotas</th>
                        	<th style="width:4em">Total Deuda</th>
                        	<th style="width:4em">De Pend.</th>
                        	<th>De Adel.</th>
                        	<th>De Sup.</th>
                        	<th>De Aut.</th>
                        	<th>De Ind.</th>
                        	<th>De Var.</th>
                        	<th>De Farm.</th>
                        	<th style="width:4em">Total A Ref.</th>
                        	<th>Ref</th>
                        </tr>
                    </thead>
                    <tbody>
                    <g:each in="${afiliados}" status="i" var="afiliadoInstance">
                        <tr class="${(i % 2) == 0 ? 'odd' : 'even'}">
                        
                        
                        	<td><g:link action="show" controller="afiliado" id="${afiliadoInstance.id}">${fieldValue(bean: afiliadoInstance, field: "legajo")}</g:link></td>
                            <td style="width:12em"><g:link action="show" controller="afiliado" id="${afiliadoInstance.id}">${fieldValue(bean: afiliadoInstance, field: "apellidoNombre")}</g:link></td>
                        	<td style="text-align:right"><g:formatNumber number="${prestamos.get(afiliadoInstance.id)?.montoCuota}" type="number" minFractionDigits="2" maxFractionDigits ="2" roundingMode="HALF_UP" /></td>
                        	<td style="text-align:right">
                        	<g:if test="${prestamos.get(afiliadoInstance.id)}">
                        		${prestamos.get(afiliadoInstance.id)?.cuotasPagadas()?.size()}/${prestamos.get(afiliadoInstance.id)?.cuotasNoPagadas()?.size()}
                        	</g:if>
                        	<g:if test="${!prestamos.get(afiliadoInstance.id)}">
                        	&nbsp;
                        	</g:if>
                        	</td>
                        	<td style="text-align:right"><g:formatNumber number="${prestamos.get(afiliadoInstance.id)?.montoTotal}" type="number" minFractionDigits="2" maxFractionDigits ="2" roundingMode="HALF_UP" /></td>
                        	<td style="text-align:right"><g:formatNumber number="${prestamos.get(afiliadoInstance.id)?.pendiente}" type="number" minFractionDigits="2" maxFractionDigits ="2" roundingMode="HALF_UP" /></td>
                        	<td style="text-align:right"><g:formatNumber number="${mapaPrestamosSubTotal.get(afiliadoInstance.id)?.get('adelantos')}" type="number" minFractionDigits="2" maxFractionDigits ="2" roundingMode="HALF_UP" /></td>
                        	<td style="text-align:right"><g:formatNumber number="${mapaPrestamosSubTotal.get(afiliadoInstance.id)?.get('consumosSuper')}" type="number" minFractionDigits="2" maxFractionDigits ="2" roundingMode="HALF_UP" /></td>
                        	<td style="text-align:right"><g:formatNumber number="${mapaPrestamosSubTotal.get(afiliadoInstance.id)?.get('consumosAuto')}" type="number" minFractionDigits="2" maxFractionDigits ="2" roundingMode="HALF_UP" /></td>
                        	<td style="text-align:right"><g:formatNumber number="${mapaPrestamosSubTotal.get(afiliadoInstance.id)?.get('consumosInd')}" type="number" minFractionDigits="2" maxFractionDigits ="2" roundingMode="HALF_UP" /></td>
                        	<td style="text-align:right"><g:formatNumber number="${mapaPrestamosSubTotal.get(afiliadoInstance.id)?.get('consumosVarios')}" type="number" minFractionDigits="2" maxFractionDigits ="2" roundingMode="HALF_UP" /></td>
                        	<td style="text-align:right"><g:formatNumber number="${mapaPrestamosSubTotal.get(afiliadoInstance.id)?.get('consumosFarmacia')}" type="number" minFractionDigits="2" maxFractionDigits ="2" roundingMode="HALF_UP" /></td>
							<td style="text-align:right"><g:formatNumber number="${mapaPrestamosSubTotal.get(afiliadoInstance.id)?.get('totalARefinanciar')}" type="number" minFractionDigits="2" maxFractionDigits ="2" roundingMode="HALF_UP" /></td>
							<td>
							<g:if test="${!prestamos.get(afiliadoInstance.id)}">
							 <modalbox:createLink url="/GTesoreria/prestamo/create?afiliado=${afiliadoInstance.id}&total=${mapaPrestamosSubTotal.get(afiliadoInstance.id)?.get('totalARefinanciar') }" title="Refinanciar" width="500">Ref</modalbox:createLink>
							 </g:if>
							 <g:if test="${prestamos.get(afiliadoInstance.id)}">
							 <modalbox:createLink url="/GTesoreria/prestamo/edit?id=${prestamos.get(afiliadoInstance.id)?.id}" title="Refinanciar" width="500">Ref</modalbox:createLink>
							 </g:if>
							</td>                           
                        
                        </tr>
                    </g:each>
                    </tbody>
                </table>
            </div>
            
        </div>
    </body>
</html>
